package poker;

import java.util.ArrayList;

public class CardUtil 
{
	public static Card[] removeByValue(Card[] hand, int value)
	{
		ArrayList<Card> newHand = new ArrayList<Card>();
		
		for (int i = 0; i < hand.length; i++) 
		{
			if(hand[i].getValue() != value)
				newHand.add(hand[i]);
		}
		
		return ListUtils.toArr(newHand);
	}
	
	public static Card[] getBySuit(Card[] hand, char suit)
	{
		ArrayList<Card> newHand = new ArrayList<Card>();
		
		for (int i = 0; i < hand.length; i++) 
		{
			if(hand[i].getSuit() == suit)
				newHand.add(hand[i]);
		}
		
		return ListUtils.toArr(newHand);
	}

	public static Card[] removeDuplicates(Card[] hand) {
		ArrayList<Card> newHand = new ArrayList<Card>();
		
		for (int i = 0; i < hand.length; i++) {
			if(!ListUtils.contains(newHand, hand[i].getValue()))
				newHand.add(hand[i]);
		}
		
		return ListUtils.toArr(newHand);
	}
	
	
}
